package com.alks.function.mapper;

import com.alks.entity.data.entity.SdDepartment;
import com.alks.function.data.dto.sys.DeptSimpleDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.mapstruct.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface SdDepartmentMapper extends BaseMapper<SdDepartment> {

    /**
     * 查询所有
     * @return
     */
    List<SdDepartment> queryAll(String companyId);

    /**
     * 查询部门数量
     * @return
     */
    Integer queryParentLevelAll(@Param("deptLevel") String deptLevel);

    Integer queryParentLevelIsNull();

    /**
     * 查询单个
     * @param deptNo
     * @return
     */
    SdDepartment getOne(@Param("deptNo") String deptNo);

    /**
     * 修改
     * @param sdDepartment
     */
    void updataDepartment(SdDepartment sdDepartment);

    /**
     * 保存
     * @param sdDepartment
     */
    void saveDept(SdDepartment sdDepartment);

    /**
     * 查询部门列表
     * @param companyId
     * @return
     */
    List<Map<String, String>> deptList(String companyId,String deptName);

    /**
     * 根据关键词搜索部门
     * @param companyId
     * @param searchKey
     * @return
     */
    List<DeptSimpleDto> selectLastCombo(@Param("companyId") String companyId, @Param("searchKey") String searchKey);

    /**
     * 查询部门是否被引用
     * @param deptNo
     * @param companyId
     * @return
     */
    int selectByDept(@Param("deptNo") String deptNo, @Param("companyId") String companyId);
}
